package com.jaya.budan.adapter;

import android.content.Context;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import java.util.List;

public class ViewPagerAdapter extends FragmentStatePagerAdapter {

    private String[] titles;
    private List<Fragment> viewPagerFragments;
    private Context mcontext;

    public ViewPagerAdapter(Context context, FragmentManager fm) {
        super(fm);
        mcontext = context;
    }
    public void setTitles(String[] titles) {
        this.titles = titles;
    }

    public void setFragments(List<Fragment> viewPagerFragments) {
        this.viewPagerFragments = viewPagerFragments;
    }

    @Override
    public Fragment getItem(int position) {
        return viewPagerFragments.get(position);
    }

    @Override
    public int getCount() {
        return viewPagerFragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
